<?php

declare(strict_types=1);

namespace Modules\Purchasing\Models;

use Catch\Base\CatchModel as Model;

/**
 * @property $id
 * @property $creator_id
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
*/
class Supplierschedule extends Model
{
    

    protected $table = 'supplierschedule';

    protected $fillable = [ 'id', 'creator_id', 'created_at', 'updated_at', 'deleted_at','supplier_id' ,'purchaseorder_id','quantity','deliverydate','number','thequantity','modifier','typebox','purchaseorderschedule_id','actual_number','fields1','fields2','fields3','fields4','fields5','fields6','fields7','fields8','fields9','fields10'];

    /**
     * @var array
     */
    protected array $fields = ['id', 'creator_id','created_at','updated_at','supplier_id' ,'purchaseorder_id','quantity','deliverydate','number','thequantity','modifier','typebox','purchaseorderschedule_id','actual_number','fields1','fields2','fields3','fields4','fields5','fields6','fields7','fields8','fields9','fields10'];

    /**
     * @var array
     */
    protected array $form = ['id', 'creator_id','created_at','updated_at','supplier_id' ,'purchaseorder_id','quantity','deliverydate','number','thequantity','modifier','typebox','purchaseorderschedule_id','actual_number','fields1','fields2','fields3','fields4','fields5','fields6','fields7','fields8','fields9','fields10'];

    /**
     * @var array
     */
    public array $searchable = [
        'supplierOrder' => 'like',
        'remarks' => 'like',
        'state' => 'like',
    ];
      
    //输出相应的时间格式
    protected function serializeDate($date)
    {
        return $date->format('Y-m-d H:i');
    }
    
    public static function getData($fields,$where){
        return self::select($fields)->where($where)->first();
    }
    
    public static function getDatajon($fields,$where){
        return self::select($fields)
        ->join('supplier as supplier','supplier.id','=','supplierschedule.supplier_id')
        ->where($where)->first();
    }

    
}
